package group.ocr.Mapper;

import group.ocr.pojo.singleCharacters;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SingleCharactersMapper {
    @Select({
            "<script>",
            "SELECT * FROM single_characters",
            "WHERE 1=1",
            "<if test='characterName != null and characterName != \"\"'>",
            "AND character_name = #{characterName}",
            "</if>",
            "<if test='font != null and font != \"\"'>",
            "AND font = #{font}",
            "</if>",
            "<if test='author != null and author != \"\"'>",
            "AND author = #{author}",
            "</if>",
            "<if test='title != null and title != \"\"'>",
            "AND title = #{title}",
            "</if>",
            "</script>"
    })
    List<singleCharacters> search(String characterName, String font, String author, String title);
    @Select("select * from single_characters where id=#{id}")
    singleCharacters selectById(int id);
    @Select("select * from single_characters")
    List<singleCharacters> selectAllSingleCharacters();
    @Insert("insert into single_characters (title,character_name,image_url,position,font,author)values(#{title},#{character_name},#{image_url},#{position},#{font},#{author})")
    void saveSingleCharacters(String title,String character_name,String image_url,String position,String font,String author);
}
